<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>中奖</title>
    <style>
    #prize{
        width:200px;
        height:50px;
        border:1px solid green;
    }
    </style>
</head>
<body>
    <div class="prize" id="prize"></div>
</body>
</html>
<script>
    function getCode(){
        var str="0123456789";
        var result="";
        for(var i=0;i<4;i++){
            var index=Math.floor(Math.random()*9);
            result+=str[index];
        }
       prize.innerHTML=result;
       return result;
    }
    var time1=setInterval(function(){
        getCode();
    },1000);

    setTimeout(function(){
        clearInterval(time1);
    },10000)
    
   
</script>